package com.example.shaomengjie.smvp.presenter.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.shaomengjie.smvp.R;
import com.example.shaomengjie.smvp.bean.TestBean;
import com.example.shaomengjie.smvp.bean.UserBean;
import com.example.shaomengjie.smvp.framework.presenter.ActivityPresenter;
import com.example.shaomengjie.smvp.net.callback.OnResultCallBack;
import com.example.shaomengjie.smvp.net.http.HttpMoudle;
import com.example.shaomengjie.smvp.net.subscriber.HttpSubscriber;
import com.example.shaomengjie.smvp.view.SimpleDelegate;

public class MainActivity extends ActivityPresenter<SimpleDelegate> implements View.OnClickListener {
    private HttpMoudle httpMoudle ;
    @Override
    protected Class<SimpleDelegate> getDelegateClass() {
        return SimpleDelegate.class;
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

    }

    @Override
    protected void bindEvenListener() {
        super.bindEvenListener();
        viewDelegate.setOnClickListener(this,R.id.button);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button:
                getData();
                break;
        }
    }
    public void getData() {
        httpMoudle = new HttpMoudle();
       /* httpMoudle.getDatasWithCache(1, 10, "json1", false,new HttpSubscriber<TestBean>(new OnResultCallBack<TestBean>() {

            @Override
            public void onSuccess(TestBean testBean) {
                viewDelegate.setTextView(testBean.toString());
            }

            @Override
            public void onError(int code, String errorMsg) {

            }
        }));*/
        httpMoudle.getLogion("10005652263","123456",new HttpSubscriber<>(new OnResultCallBack<UserBean>() {
            @Override
            public void onSuccess(UserBean userBean) {

            }
        },this));
    }
}
